<?php


namespace app\services\exam;


use app\dao\exam\ExamQuestionImgDao;
use app\exceptions\AdminException;
use app\services\BaseService;

class ExamQuestionImgService extends BaseService
{
    public function __construct(ExamQuestionImgDao $dao)
    {
        $this ->dao = $dao;
    }


    /*
     * 保存学生题目提交图片
     */
    public function createImg(array $where){
        $data = $this->dao->isCunzai($where);

        if ($data){
            $data = $this->dao->updateImg($where);
        }else{
            $data = $this->dao->createImg($where);
        }
        if (!$data) {
            throw new AdminException('保存失败');
        }
        return '保存成功';

    }

    /*
     * 获取学生题目保存图片
     */
    public function getImg(array $where){
        return $this->dao->isCunzai($where);
    }

    public function getQuestion(array $where)
    {
        return $this->dao->getQuestion($where);
    }
}